#ifndef MUSICWINDOW_H
#define MUSICWINDOW_H

#include <QMainWindow>
#include <QStandardItemModel>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QVector>
#include <QMediaPlayer>
#include <QMediaPlaylist>
#include "customdelegate.h"

namespace Ui {
class musicWindow;
}

//一首歌的信息
struct musicNode
{
    musicNode(int id, QString songname_original, QString singername, QString album_name, int duration )
    {
        this->id = id;
        this->songname_original = songname_original;
        this->singername = singername;
        this->album_name = album_name;
        this->duration = duration;
    }
    int id;                    //歌曲ID
    QString songname_original; //歌曲名
    QString singername;        //歌手
    QString album_name;        //专辑
    int duration;          	//时间
};

class musicWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit musicWindow(QWidget *parent = nullptr);
    ~musicWindow();
    void setComebackWindow(QWidget * pWindow);
    void parseJson(QByteArray json);
    CustomDelegate *delegate;
private slots:
    void on_pushButton_clicked();
    //函数参数是因为finish信号携带了这个参数，所以槽函数也要添加，用来接受信号传递过来的数据
    void get_http_mes_slot(QNetworkReply *reply);
    void on_pushButton_3_clicked();

    void on_tableView_doubleClicked(const QModelIndex &index);
    void durationChanged_slot(int duration);
    void positionChanged_slot(qint64 current_postion);
    void on_horizontalSlider_sliderPressed();

    void on_horizontalSlider_sliderReleased();

private:
    Ui::musicWindow *ui;
    QWidget *pComebackWindow;//指向返回窗口的指针
    QStandardItemModel * m_pModel;//标准的数据模型，里面可以放置数据
    QNetworkAccessManager * http;//网络访问管理类
    QVector<musicNode*> musicInfo;//歌曲信息数组
    QMediaPlayer *player;//播放器
    QMediaPlaylist *playlist;//播放列表
};

#endif // MUSICWINDOW_H
